//
//  AnimationGroupViewController.m
//  30303Animations
//
//  Created by student on 16/3/18.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "AnimationGroupViewController.h"

@interface AnimationGroupViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *plane;

@end

@implementation AnimationGroupViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //贝塞尔曲线路径
    UIBezierPath *bezierPath=[UIBezierPath bezierPath];
    [bezierPath moveToPoint:CGPointMake(10.0, 10.0)];
    [bezierPath addQuadCurveToPoint:CGPointMake(100, 300) controlPoint:CGPointMake(300, 100)];
    
    CAKeyframeAnimation *posAnmi=[CAKeyframeAnimation animationWithKeyPath:@"position"];
    posAnmi.path=bezierPath.CGPath;
    posAnmi.removedOnCompletion=YES;
    
    CABasicAnimation *scaleAnim=[CABasicAnimation animationWithKeyPath:@"transform.scale"];
    scaleAnim.fromValue=@0.5;
    scaleAnim.toValue=@2;
    
    CABasicAnimation *opactiyAnim=[CABasicAnimation animationWithKeyPath:@"opacity"];
    opactiyAnim.fromValue=@0.5;
    opactiyAnim.toValue=@1;
    
    CAAnimationGroup *group = [CAAnimationGroup animation];
    group.animations=@[posAnmi,scaleAnim,opactiyAnim];
    group.duration = 1;
    
    [self.plane.layer addAnimation:group forKey:nil];
}

@end
